home *** CD-ROM | disk | FTP | other *** search
- Path: erich.triumf.ca!bennett
- From: bennett@erich.triumf.ca (P.Bennett)
- Newsgroups: comp.lang.c
- Subject: Re: HELP. How to convert '0x12' into FF char?
- Date: 17 Mar 1996 23:53 PST
- Organization: TRIUMF: Tri-University Meson Facility
- Distribution: world
- Message-ID: <17MAR199623533662@erich.triumf.ca>
- References: <4iissm$s76@nntp.ucs.ubc.ca>
- NNTP-Posting-Host: erich.triumf.ca
- News-Software: VAX/VMS VNEWS 1.50
-
- In article <4iissm$s76@nntp.ucs.ubc.ca>, gordonw@unixg.ubc.ca (Gordon Wong) writes...
- >Let's say we have d='1' and e='2' and the following code segment:
-
- >f='0x';
- >strcpy(f,d);
- >strcpy(f,e);
- >
- >f now contains the string '0x12' right?
-
- No.
- but if you have:
- char f[10] = "0x";
- char d[2] = "1";
- char e[2] = "2";
- strcpy(f,d);
- strcpy(f,e);
- f will then contain the string "0x12".
- Note that single quotes (') are used to delimit a single char. double quotes
- (") are used to delimit a string (one or more chars terminated with a zero
- byte)
-
-
- >How would I write that out as a single ASCII FF character?
- >(d,e,f are char)
-
- With my revision above...
- int i;
- sscanf(f, "%d", i);
- putchar(i); /* or printf("%c", i);
-
-
- Peter Bennett VE7CEI | Vessels shall be deemed to be in sight
- Internet: bennett@triumf.ca | of one another only when one can be
- Packet: ve7cei@ve7kit.#vanc.bc.ca | observed visually from the other
- TRIUMF, Vancouver, B.C., Canada | ColRegs 3(k)
- GPS and NMEA info and programs: ftp://sundae.triumf.ca/pub/peter/index.html
- or: ftp://ftp-i2.informatik.rwth-aachen.de/pub/arnd/GPS/peter/index.html
-
-